#ifndef _KEY_H
	#define _KEY_H
	
#include "stm32f10x.h"

extern u32 TimingDelay;
extern u8 alarm_flag;

#define RB1 GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_0)
#define RB2 GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_8)
#define RB3 GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_1)
#define RB4 GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_2)

#define key1 1
#define key2 2
#define key3 3
#define key4 4

#define led GPIO_Pin_8

#define state_realTime_showing 0x00
#define state_realTime_hour_setting 0x01
#define state_realTime_min_setting 0x02
#define state_realTime_sec_setting 0x03
#define state_temper_showing 0x06

#define state_clockTime_hour_setting 0x10
#define state_clockTime_min_setting 0x11
#define state_clockTime_sec_setting 0x12

void key_init(void);
void led_init(void);
void delay_ms(u32 nTime);
void led_ctrl(u8 status);
u8 key_scan(void);
void deal_alarm(void);
void deal_state(void);

#endif